import {defineStore} from "pinia";
import axios from "axios";


//第一个参数是唯一storeId
const useCinemaStore = defineStore("cinema",{

    state:()=>({
        cinemaList:[]
    }),
    actions: {
        async getCinemaList(){
            let res = await axios({
                url: "https://m.maizuo.com/gateway?cityId=110100&ticketFlag=1&k=7147275",
                headers: {
                    'X-Client-Info': '{"a":"3000","ch":"1002","v":"5.2.1","e":"1700982879663830145269761"}',
                    'X-Host': 'mall.film-ticket.cinema.list',
                }
            })
            this.cinemaList =  res.data.data.cinemas
        }
    },
    getters:{
        filterCinemaList(state){
            return (type)=> state.cinemaList.filter(item => item.eTicketFlag === type)
        }
    }
})

export default useCinemaStore